﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZX.BLL.Extend;
using ZX.CRM.Library;
using System.Data.SqlClient;
using System.Data;
using ZX.DAL.DBExtend;

namespace ZX.CRM.Bussiness
{
    public class BCrmProductPack : BaseBussnies
    {
        /// <summary>
        /// 获取所有产品包信息
        /// </summary>
        /// <returns></returns>
        public IList<CrmProductPack> GetAllProductPack()
        {
            this.entity = new CrmProductPack();
            return GetEntitysBySqlComm<CrmProductPack>("select * from CrmProductPack order by Addtime");
        }
        /// <summary>
        /// 获取所有产品包信息
        /// </summary>
        /// <returns></returns>
        public IList<CrmProductPack> GetAllProductPackByID()
        {
            this.entity = new CrmProductPack();
            return GetEntitysBySqlComm<CrmProductPack>("select * from CrmProductPack where ID='4BA06954-FD31-4F13-8A35-DC86E09D020C' or ID='69D95664-04E2-4941-9381-B7E5369A6D64' or ID='183945EC-E58B-43F3-BAB1-74C98FAE911B' order by Addtime");
        }
        /// <summary>
        /// 根据产品包ID获取产品包信息
        /// </summary>
        /// <param name="PackId"></param>
        /// <returns></returns>
        public V_CrmProductPack GetProductPackById(Guid PackId)
        {
            this.entity = new V_CrmProductPack();
            return GetEntityByCondition("ID='" + PackId + "'") as V_CrmProductPack;
        }
        /// <summary>
        /// 根据包ID获取所有包详细信息
        /// </summary>
        /// <param name="PackId"></param>
        /// <returns></returns>
        public IList<V_CrmPackDetail> GetAllPackDetailByPackId(Guid PackId)
        {
            this.entity = new V_CrmPackDetail();
            return GetEntitysBySqlComm<V_CrmPackDetail>("select * from V_CrmPackDetail where PackID='" + PackId + "'");
        }
        /// <summary>
        /// 获取默认值结果                
        /// </summary>
        /// <param name="sdate"></param>
        /// <param name="edate"></param>
        /// <returns></returns>
        public string ReturnDefaultValue(Guid gd)
        {
            int iResult = 0;
            DbSql execsql = new DAL.DBExtend.DbSql();
            IDataParameter[] _Parameters = new IDataParameter[] { };
            SqlParameter spOpid = new SqlParameter("@OrderProductId", SqlDbType.UniqueIdentifier, 50);
            spOpid.Direction = ParameterDirection.Input;
            spOpid.Value = gd;
            SqlParameter ReturnValue = new SqlParameter("@ReturnValue", SqlDbType.NVarChar, 50);
            ReturnValue.Direction = ParameterDirection.Output;

            _Parameters = new IDataParameter[] { spOpid, ReturnValue };

            return execsql.RunProcedureReturnString("Sp_GetCrmOrderProductCheck", _Parameters, out iResult);
        }
    }
}
